<template>
	<view style="padding: 20rpx 40rpx;">
		<view>
			<u--form labelPosition="left" labelWidth="180rpx" :model="form" ref="uForm">

				<u-form-item label="发帖类型:" prop="form.type" borderBottom @click="()=>{showType = true}" ref="item1">
					<u--input v-model="form.type" disabled disabledColor="#ffffff" placeholder="发帖类型"
						border="none"></u--input>
					<u-icon slot="right" name="arrow-right"></u-icon>
				</u-form-item>
				<u-form-item label="主题" prop="form.subject" borderBottom ref="subject">
					<u--input v-model="form.subject" placeholder="例如 快递代取出资料等" border="none"></u--input>
				</u-form-item>
				<u-form-item label="源地址" prop="form.fromAddress" borderBottom ref="fromAddress">
					<u--input v-model="form.fromAddress" placeholder="非代取拼车业务请填无" border="none"></u--input>
				</u-form-item>
				<u-form-item label="目标地址" prop="form.toAddress" borderBottom ref="toAddress">
					<u--input v-model="form.toAddress" border="none" placeholder="非代取拼车业务请填无"></u--input>
				</u-form-item>
				<u-form-item label="出发时间" prop="form.time" borderBottom ref="time">
					<u--input v-model="form.time" border="none" placeholder="非拼车业务请填无"></u--input>
				</u-form-item>
				<u-form-item label="金额/人数" prop="form.number" borderBottom ref="number">
					<u--input v-model="form.number" type="digit" border="none"></u--input>
				</u-form-item>
				<u-form-item label="详细信息" prop="form.descript" borderBottom ref="descript">
					<u--textarea v-model="form.descript" placeholder="请输入内容"></u--textarea>
				</u-form-item>
				<u-form-item label="上传图片" prop="form.file" borderBottom ref="descript">
					<u-upload :fileList="form.file" @afterRead="afterRead"  name="1" multiple
						:maxCount="10"></u-upload>
				</u-form-item>
			</u--form>
		</view>
		<view style="margin-top: 10rpx;">
			<u-button type="info " :plain="true" text="点击发帖" @click="handlerPush"></u-button>
		</view>
		<view>
			<u-action-sheet :show="showType" :actions="actions" title="请选择" description=" " @close="showType = false"
				@select="handlsershowTypeSelect">
			</u-action-sheet>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				actions: [{
						name: "跑腿/代办/取快递"
					},
					{
						name: "拼车"
					},
					{
						name: "其他"
					},
				],
				showType: false,
				form: {
					type: "",
					subject: "",
					fromAddress: "",
					toAddress: "",
					number: "",
					descript:"",
					file:""

				}
			}
		},
		methods: {
			afterRead({file}){
				this.form.file=[
					{
						...file[0]
					}
				]
			},
			handlerPush(){
				console.log('>>>>>>>>>>this.form',this.form)
				if(!/[\w\u4e00-\u9fa5]+/.test(this.form.type)){
					uni.showToast({
					title:"类型不能为空",
					icon:"none",
					})
					return
				}
				if(!/[\w\u4e00-\u9fa5]+/.test(this.form.subject)){
					uni.showToast({
					title:"主题不能为空",
					icon:"none",
					})
					return
				}
				if(!/[\w\u4e00-\u9fa5]+/.test(this.form.fromAddress)){
					uni.showToast({
					title:"源地址不能为空",
					icon:"none",
					})
					return
				}
				if(!/[\w\u4e00-\u9fa5]+/.test(this.form.toAddress)){
					uni.showToast({
					title:"目标地址不能为空",
					icon:"none",
					})
					return
				}
				if(!/[\w\u4e00-\u9fa5]+/.test(this.form.number)){
					uni.showToast({
					title:"金额/人数不能为空",
					icon:"none",
					})
					return
				}
				if(!/[\w\u4e00-\u9fa5]+/.test(this.form.descript)){
					uni.showToast({
					title:"描述不能为空",
					icon:"none",
					})
					return
				}
				if(!/[\w\u4e00-\u9fa5]+/.test(this.form.file)){
					uni.showToast({
					title:"图片不能为空",
					icon:"none",
					})
					return
				}
				uni.navigateTo({
					url:"/pages/post/post"
				})
			},
			handlsershowTypeSelect(res) {
				this.form.type = res.name
			}
		}
	}
</script>

<style>

</style>